//
//  MineListViewController.m
//  Mahjong
//
//  Created by KING on 16/9/1.
//  Copyright © 2016年 swift. All rights reserved.
//

#import "MineListViewController.h"
#import "MoreSelectView.h"
#import "Header.h"
#import "MineListNumberTableViewCell.h"
#import "MineListAdressTableViewCell.h"
#import "MineListConTableViewCell.h"
#import "MineListDetailViewController.h"
#import "MineListTwoDetailViewController.h"
#import "MineListAlreDetailViewController.h"
#import "MineListUnDetailViewController.h"
#import "MIneListEvaluationDetailViewController.h"

#import "MIneListHomeViewController.h"
#import "MineAdressHomeViewController.h"
#import "MineAdressViewController.h"
@interface MineListViewController ()<selectDelegate,UITableViewDelegate,UITableViewDataSource,UIScrollViewDelegate>
@property (nonatomic, retain) UIButton *brandButton;
@property (nonatomic, retain) UIButton *itemButton;
@property (nonatomic, retain) UIScrollView *bigScrollView;
@property (nonatomic, strong) MoreSelectView *selectView;
@property (nonatomic, strong) NSArray *topArray;
@property (nonatomic, strong) UITableView *myTableView;
@property (nonatomic, strong) NSArray *titleArray;
@property (nonatomic, assign) NSInteger number;
@end

@implementation MineListViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
//    self.navigationController.navigationBar.translucent = NO;
    self.view.backgroundColor =  KRGBColor(239, 239, 239);
    _selectView = [[MoreSelectView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 40)];
    [self.view addSubview:_selectView];
    _selectView.myDelegate = self;
    
    
    self.bigScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREENH_HEIGHT- (51*SCREEN_WIDTH)/375)];
    [self.view addSubview:self.bigScrollView];
    self.bigScrollView.contentSize = CGSizeMake(SCREEN_WIDTH *2,0);
    self.bigScrollView.pagingEnabled = YES;
    self.bigScrollView.bounces = NO;
    self.bigScrollView.delegate = self;

    MIneListHomeViewController *favVC = [[MIneListHomeViewController alloc] init];
    [self addChildViewController:favVC];
    favVC.view.frame = CGRectMake(SCREEN_WIDTH, (51*SCREEN_WIDTH)/375, SCREEN_WIDTH, SCREENH_HEIGHT);
    [self.bigScrollView addSubview:favVC.view];
    
    MineAdressViewController *hisVC = [[MineAdressViewController alloc] init];
    hisVC.view.frame = CGRectMake(0, (51*SCREEN_WIDTH)/375, SCREEN_WIDTH, SCREENH_HEIGHT);
    [self addChildViewController:hisVC];
    [self.bigScrollView addSubview:hisVC.view];

    
    self.tabBarController.tabBar.hidden = YES;
    self.navigationController.navigationBar.translucent = NO;
    


    self.navigationItem.title = @"我的订单";
    
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"nav_but_back"] style:(UIBarButtonItemStyleDone) target:self action:@selector(backAction)];
    backItem.tintColor = [UIColor grayColor];
    self.navigationItem.leftBarButtonItem = backItem;
    [self createButton];
    
    
    
  
    
}

- (void)backAction{
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)createButton{
    //商品
    self.brandButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.brandButton.frame = CGRectMake(0, 0, SCREEN_WIDTH / 2.0, (50*SCREEN_WIDTH)/375);
    self.brandButton.backgroundColor = [UIColor redColor];
    [self.brandButton setTitle:@"购物订单" forState:UIControlStateNormal];
    
    //    self.brandButton.titleLabel.font = [UIFont systemFontOfSize:];
    [self.view addSubview:self.brandButton];
    [self.brandButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    
    
    //宝贝
    self.itemButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.itemButton.frame = CGRectMake(SCREEN_WIDTH / 2.0, 0, SCREEN_WIDTH / 2.0, (50*SCREEN_WIDTH)/375);
    self.itemButton.backgroundColor = [UIColor whiteColor];
    [self.itemButton setTitle:@"定制订单" forState:UIControlStateNormal];
    [self.itemButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //    self.itemButton.titleLabel.font = [UIFont systemFontOfSize:0.037*SCREEN_WIDTH];
    [self.view addSubview:self.itemButton];
    [self.itemButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
}
#pragma mark - 点击按钮会滑到相应页
- (void)buttonAction:(UIButton *)btn{
    if (btn == self.brandButton) {
        [self.bigScrollView setContentOffset:CGPointMake(0, 0) animated:YES];
        
    } else {
        [self.bigScrollView setContentOffset:CGPointMake(SCREEN_WIDTH, 0) animated:YES];
        
    }
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    
    NSInteger a = self.bigScrollView.contentOffset.x / SCREEN_WIDTH;
    
    switch (a) {
        case 0:
            
            [self.brandButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            self.brandButton.backgroundColor = [UIColor redColor];
            [self.itemButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            self.itemButton.backgroundColor = [UIColor whiteColor];
            
            break;
        case 1:
            [self.itemButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            self.itemButton.backgroundColor = [UIColor redColor];
            [self.brandButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            self.brandButton.backgroundColor = [UIColor whiteColor];
            
            break;
            
        default:
            break;
    }
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
